/**
 * 
 */
package tutorial;

 
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.classic.Session;
/**
 * HISTORY
 *
 * @author Administrator
 * @createtime 2010-1-22 下午01:46:20
 *
 */

public class MainApp {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
	 
		Session session = null;

		try{
			// This step will read hibernate.cfg.xml and prepare hibernate for use
	 
			SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
			 session =sessionFactory.openSession();
				//Create new instance of Contact and set values in it by reading them from form object
			 	System.out.println("Inserting Record");
			 	Book book = new Book();
			 	book.setBookId(4);
			 	book.setBookName("Java persistent with Hibernate");
				 
				session.save(book);
				System.out.println("Done");
		}catch(Exception e){
		}finally{
			// Actual contact insertion will happen at this step
			session.flush();
			session.close();

			}
		

	}

}
